'''API Warehouse'''

from spass.core.warehouse import (core_w_new_assignment_version,
                                  core_w_del_assignment_version,
                                  core_w_list_assignment_versions,
                                  core_w_list_assignment_tests,
                                  core_w_new_assignment_version_file,
                                  core_w_list_assignment_version_files,
                                  core_w_list_assignment_version_tests,
                                  core_w_get_assignment_version_file,
                                  core_w_get_assignment_version_test,
                                  core_w_get_assignment_version,
                                  core_w_get_assignment_team,
                                  core_w_get_assignment,
                                  core_w_del_assignment_team,
                                  core_w_del_assignment,
                                  core_w_del_template)

def wnew_assignment_version(id_assignment, id_team):
    ''' Creates a new assignment version and return its ID '''
    return core_w_new_assignment_version(id_assignment, id_team)

def wdel_assignment_version(id_assignment, id_team, id_version):
    ''' Deletes an assignment version '''
    return core_w_del_assignment_version(id_assignment, id_team, id_version)

def wlist_assignment_versions(id_assignment, id_team):
    ''' Lists all assignment versions for a team in an assignment'''
    return core_w_list_assignment_versions(id_assignment, id_team)

def wlist_assignment_tests(id_assignment):
    ''' Lists all tests for an assignment'''
    return core_w_list_assignment_tests(id_assignment)

def wadd_assignment_version_file(id_assignment, id_team, id_version, file_path):
    ''' Add a new file in an assignment version '''
    return core_w_new_assignment_version_file(id_assignment,
                                              id_team, id_version, file_path)

def wlist_assignment_version_files(id_assignment, id_team, id_version):
    ''' Lists all files of an assignment version '''
    return core_w_list_assignment_version_files(id_assignment,
                                                id_team, id_version)

def wlist_assignment_version_tests(id_ass, id_team, id_version):
    ''' Lists all test logs of an assignment version '''
    return core_w_list_assignment_version_tests(id_ass, id_team, id_version)

def wget_assignment_version_file(id_assignment, id_team,
                                 id_version, file_name, file_target):
    ''' Exports a file from an assignment version to the "file_target" path '''
    return core_w_get_assignment_version_file(id_assignment, id_team,
                                              id_version, file_name,
                                              file_target)

def wget_assignment_version_test(id_ass, id_team, id_version,
                                 test_name, file_target):
    '''
    Exports a test logs from an assignment version to the "file_target" path
    '''
    return core_w_get_assignment_version_test(id_ass, id_team, id_version,
                                              test_name, file_target)

def wget_assignment_version(id_assignment, id_team,
                            id_version, dir_target):
    '''
    Exports an assignment version
    to "dir_target/id_assignment.id_team.id_version"
    '''
    return core_w_get_assignment_version(id_assignment, id_team,
                                         id_version, dir_target)

def wget_assignment_team(id_assignment, id_team, dir_target):
    '''
    Exports all assignment versions of a team to "dir_target/id_assignment.id_team"
    '''
    return core_w_get_assignment_team(id_assignment, id_team, dir_target)

def wget_assignment(id_assignment, dir_target):
    ''' Exports the wall assignment content to "dir_target/id_assignment" '''
    return core_w_get_assignment(id_assignment, dir_target)


def wdel_assignment_team(id_assignment, id_team):
    ''' Deletes a team folder from an assignment in the warehouse'''
    return core_w_del_assignment_team(id_assignment, id_team)

def wdel_assignment(id_assignment):
    ''' Deletes an assignment folder in the warehouse'''
    return core_w_del_assignment(id_assignment)

def wdel_template(id_template):
    ''' Deletes a template folder in the warehouse '''
    return core_w_del_template(id_template)
